import {ref,onMounted,onUnmounted} from 'vue'

function useMouseTrack () {
    const x = ref(0)
    const y = ref(0)

    const updatePosition = (e: MouseEvent) => {
        x.value = e.clientX
        y.value = e.clientY
    }

    onMounted(() => {
        document.addEventListener('click',updatePosition)
    })

    onUnmounted(() => {
        document.removeEventListener('click',updatePosition)
    })

    return {x,y}
}

export default useMouseTrack